﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace QLHH_HD
{
    class DALHoaDon
    {
        public DALHoaDon()
        {

        }
        public DataTable DocDanhSachHoadon()
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "Data source=(local); initial catalog=qlvt; user id=sa;password=sa";
            conn.Open();
            SqlCommand cmd = new SqlCommand("select sohd,tenhang,soluong,dongia,trigia,khuyenmai,diengiai from hoadon INNER JOIN hanghoa ON hoadon.mahang=hanghoa.mahang ORDER BY sohd ", conn);
            SqlDataReader dr = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(dr);
            return dt;
        }
        public void XoaHoaDon(String sohd)
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "Data source=(local); initial catalog=qlvt; user id=sa;password=sa";
            conn.Open();
            SqlCommand cmd = new SqlCommand("delete from hoadon where sohd='" + sohd + "'", conn);
            cmd.ExecuteNonQuery();
        }
        public void ThemHoaDon(string sohd, string mah)
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "data source=(local); initial catalog=qlvt; userId=sa; password=sa";
            conn.Open();
            SqlCommand cmd = new SqlCommand("insert into hoadon values('HD05', N'04',5, 7000000,35000000,NULL", conn);
            cmd.ExecuteNonQuery();
        }

        internal void ThemHoaDon(string sohoadon, string mahang, int soluong, double dongia, double trigia, double khuyenmai, string diengiai)
        {
            throw new NotImplementedException();
        }
    }

}
    
